package 方法的抽象和逐步求精;

public class Exercise5_2 {

	/**
	 * 各位数之和
	 * @param n
	 * @return
	 */
	public static int sumDigite(long n){
		int temp = (int)Math.abs(n);
		int sum = 0;
		while(temp != 0){
			int remainder = temp % 10;
			sum += remainder;
			temp = temp/10;
		}
		return sum;
	}
	
	public static void main(String[] args) {
		int i = sumDigite(1234567);
		System.out.println(i);
	}
}
